-------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/jesse/Dropbox/voter_id/Replication/figure2.log
  log type:  text
 opened on:  17 Aug 2020, 10:25:58

. 
. use "$path/didnt_have_id.dta", clear

. 
. rename county_id county

. merge m:m county voter_reg_num using "$path/voter_file.dta", keep(1 3) nogen

    Result                           # of obs.
    -----------------------------------------
    not matched                           151
        from master                       151  
        from using                          0  

    matched                             1,020  
    -----------------------------------------

. 
. // merge in list of no DMV matches
. merge m:1 ncid using "$path/no_dmv_match.dta", keep(1 3) nogen

    Result                           # of obs.
    -----------------------------------------
    not matched                           986
        from master                       986  
        from using                          0  

    matched                               185  
    -----------------------------------------

. replace no_dmv_match = 0 if no_dmv_match == .
(986 real changes made)

. 
. keep last_name first_name pv_name pv_status no_dmv_match

. 
. gen vf_name = last_name + "," + first_name

. order vf_name, after(pv_name)

. 
. split pv_name, parse(",")
variables created as string: 
pv_name1  pv_name2

. rename pv_name1 pv_last_name

. gen last_match = pv_last_name == last_name

. gen pv_first_name = word(pv_name2, 1)

. gen first_match = pv_first_name == first_name

. gen match = last_match | first_match

. 
. bysort pv_status: tab no_dmv_match if match

-------------------------------------------------------------------------------------------------
-> pv_status = NOT COUNTED

no_dmv_matc |
          h |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |        832       81.81       81.81
          1 |        185       18.19      100.00
------------+-----------------------------------
      Total |      1,017      100.00

-------------------------------------------------------------------------------------------------
-> pv_status = PARTIAL

no_dmv_matc |
          h |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |          2      100.00      100.00
------------+-----------------------------------
      Total |          2      100.00


. 
. gen pv = match & pv_status == "NOT COUNTED"

. 
. gen dmv_match = no_dmv_match == 0

. keep dmv_match no_dmv_match pv

. 
. gen pv_text = ""
(1,171 missing values generated)

. drop if pv == 0
(154 observations deleted)

. replace pv_text = "Provisional Ballot Rejected for Lack of ID" if pv == 1
variable pv_text was str1 now str42
(1,017 real changes made)

. 
. // append dataset we used for descriptive stats so that no_dmv_match rate is same as in descrip
> tive stats table
. append using "$path/nc_dataset.dta", keep(no_dmv_match birth_year ///
>         hispanic black white othernw id new_reg voted)

. drop if new_reg == 1
(11,975,136 observations deleted)

. drop new_reg

. egen non_miss = rownonmiss(hispanic black white othernw birth_year voted)

. gen in_sample = non_miss == 6

. drop hispanic black white othernw birth_year voted

. drop if in_sample == 0 & pv == .
(1,762,752 observations deleted)

. replace pv = 0 if pv == .
(77,765,076 real changes made)

. replace id = _n if pv == 1
(1,017 real changes made)

. replace dmv_match = 1 if no_dmv_match == 0 
(75,406,548 real changes made)

. replace dmv_match = 0 if no_dmv_match == 1
(2,358,528 real changes made)

. drop non_miss in_sample

. bysort id pv: gen temp = _n 

. drop if temp > 1
(71,284,653 observations deleted)

. drop id temp

. compress
  variable pv was float now byte
  variable dmv_match was float now byte
  (38,888,640 bytes saved)

. replace pv_text = "All Registrants" if pv_text == ""
(6,480,423 real changes made)

. 
. graph bar (mean) dmv_match no_dmv_match, over(pv_text, label(labsize(medium))) blabel(total, 
> format(%9.3f)) ///
>         legend(off)

.         
. graph export "$path/figure2.pdf", replace
(file ~/Dropbox/voter_id/Replication/figure2.pdf written in PDF format)

. 
. log close
      name:  <unnamed>
       log:  /Users/jesse/Dropbox/voter_id/Replication/figure2.log
  log type:  text
 closed on:  17 Aug 2020, 10:53:26
-----------------------------------------------------------------------------------------------
